package com.xiaoc.bulldozer.common.dto;

import com.xc.framework.common.utils.BeanUtil;
import com.xiaoc.bulldozer.common.converter.Converter;
import com.xiaoc.bulldozer.common.model.Account;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.springframework.data.annotation.Transient;

/**
 * Account Dto
 *
 * @author Danfo Yam
 * @date 2018-08-24 15:47:58
 */
public class AccountDto extends Account {

    private static final long serialVersionUID = 1L;

    private Integer parentUserId;

    private String locationCity;

    private String locationAddress;

    private String nickName;

    private String gender;

    private String city;

    private String province;

    private String country;

    private String avatarUrl;

    private String subBankName;

    private String typeName;

    private Integer totalCount = 0;

    private Integer effectiveCount = 0;

    private Integer managerCount = 0;

    private Integer innerCount = 0;

    private Integer externalCount = 0;

    private Integer cnt = 0;

    private String date;

    /**
     * 验证码
     */
    private String code;

    /**
     * 是否分享达人 0否1是
     */
    private Integer isShareTalent;


    public Integer getParentUserId() {
        return parentUserId;
    }

    public void setParentUserId(Integer parentUserId) {
        this.parentUserId = parentUserId;
    }

    public String getLocationAddress() {
        return locationAddress;
    }

    public void setLocationAddress(String locationAddress) {
        this.locationAddress = locationAddress;
    }

    public String getLocationCity() {
        return locationCity;
    }

    public void setLocationCity(String locationCity) {
        this.locationCity = locationCity;
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public String getAvatarUrl() {
        return avatarUrl;
    }

    public void setAvatarUrl(String avatarUrl) {
        this.avatarUrl = avatarUrl;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getSubBankName() {
        return subBankName;
    }

    public void setSubBankName(String subBankName) {
        this.subBankName = subBankName;
    }

    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }

    public Integer getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(Integer totalCount) {
        this.totalCount = totalCount;
    }

    public Integer getEffectiveCount() {
        return effectiveCount;
    }

    public void setEffectiveCount(Integer effectiveCount) {
        this.effectiveCount = effectiveCount;
    }


    public Integer getInnerCount() {
        return innerCount;
    }

    public void setInnerCount(Integer innerCount) {
        this.innerCount = innerCount;
    }

    public Integer getManagerCount() {
        return managerCount;
    }

    public void setManagerCount(Integer managerCount) {
        this.managerCount = managerCount;
    }

    public Integer getExternalCount() {
        return externalCount;
    }

    public Integer getIsShareTalent() {
        return isShareTalent;
    }

    public void setIsShareTalent(Integer isShareTalent) {
        this.isShareTalent = isShareTalent;
    }

    public void setExternalCount(Integer externalCount) {
        this.externalCount = externalCount;
    }

    public Integer getCnt() {
        return cnt;
    }

    public void setCnt(Integer cnt) {
        this.cnt = cnt;
    }

    public String getDate() {
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }


    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this,
                ToStringStyle.SHORT_PREFIX_STYLE);
    }


    public Account convertToAccount(){
        AccountDTOConvert accountDTOConvert = new AccountDTOConvert();
        Account convert = accountDTOConvert.doForward(this);
        return convert;
    }

    public AccountDto convertFor(Account account){
        AccountDTOConvert accountDTOConvert = new AccountDTOConvert();
        AccountDto convert = accountDTOConvert.doBackward(account);
        return convert;
    }

    private static class AccountDTOConvert extends Converter<AccountDto, Account> {

        @Override
        protected Account doForward(AccountDto accountDto) {
            Account account = new Account();
            BeanUtil.copyProperties(accountDto, account);
            return account;
        }

        @Override
        protected AccountDto doBackward(Account account) {
            AccountDto accountDTO = new AccountDto();
            BeanUtil.copyProperties(account, accountDTO);
            return accountDTO;
        }

    }
}
